#coding:utf-8
import os
from time import sleep
from case.fyw_login import core_login, corp_login
from common.MngApiData import MngApiData

__author__ = 'yangxianming'

import json
import requests

'''
企业后管购卡，核心后管审核通过
'''

def case_describe():
    #就是用例的文字描述，说明一下你的用例做了写什么
    desc = ""
    return desc

def case():
    #初始化必要的参数
    mng_api_data = MngApiData()
    tf = True
    test_result = ""

    ##登陆
    jsessionid = core_login()
    core_headers = {
        "Cookie":"JSESSIONID="+jsessionid+"; user=%E8%B6%85%E7%BA%A7%E7%AE%A1%E7%90%86%E5%91%98",
        "Content-Type":"text/plain;charset=UTF-8",
        "Accept":"application/json, text/plain, */*"
    }

    corp_jsessionid = corp_login()
    corp_headers = {
        "Content-Type":"text/plain;charset=UTF-8",
        "Cookie":"UM_distinctid=17c111583c6213-0344cc66aa23b58-4c3e2778-1fa400-17c111583c734e; JSESSIONID="+corp_jsessionid+"; user=%E7%A6%8F%E5%91%98%E5%A4%96",
        "Accept":"application/json, text/plain, */*"}
    print(corp_headers)

    #企业后管购卡
    url = "https://fywmngdev.e-fuli.com/mngWeb/mng"
    p = mng_api_data.efuli_appmng_welfarecard_order_place_data()
    r = requests.post(url, json.dumps(p), headers=corp_headers)
    print(r.json())
    order_id = r.json()["return_data"]["orders"][0]["orderId"]
    print("order_id:" + order_id)

    #企业后管支付
    # body = mng_api_data.efuli_appmng_welfarecard_order_payment_data()["body"]
    # body["orderId"] = order_id
    # p = mng_api_data.efuli_appmng_welfarecard_order_payment_data(update_body={"body":body})
    # r = requests.post(url, json.dumps(p), headers=corp_headers)
    # print(r.json())

    ##核心后管审核同意
    # url = "https://fywmngdev.e-fuli.com/mngWeb/mng"
    # body = mng_api_data.efuli_coremng_welfarecard_order_audit_data()["body"]
    # body["orderId"] = order_id
    # p = mng_api_data.efuli_coremng_welfarecard_order_audit_data(update_body={"body":body})
    # r = requests.post(url, json.dumps(p), headers=core_headers)
    # print(r.json())
    # return_desc = r.json()["return_desc"]

    return ""

case()